package rp.account;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import utils.JDBC;

import java.util.Set;

public class LSNAccount implements Listener {
    private JDBC jdbc;

    @EventHandler
    public void onLogin(PlayerJoinEvent e) throws Exception {
        Player player = e.getPlayer();
        Set<String> tags = player.getScoreboardTags();
        if (jdbc.get("select * from user where name = " + player.getName()).first()) {
            if (!tags.contains("login"))
                tags.add("login");
        } else {
            if (!tags.contains("register"))
                tags.add("register");
        }
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent e){
        Player player = e.getPlayer();
    }

    public LSNAccount(JDBC jdbc) {
        this.jdbc = jdbc;
    }
}
